package com.design.pattern.structure.flyweight.ticket;

import java.util.HashMap;
import java.util.Map;

public class TickFactory {
    private static Map<String,ITicket> pool = new HashMap<>();

    public static ITicket queryTicket(String from, String to) {
        String key = from + "->" + to;
        if(pool.containsKey(key)) {
            System.out.println("使用缓存" + key);
            return pool.get(key);
        }
        System.out.println("首次查询，创建对象：" + key);
        return null;
    }
}
